package com.connection.second.wallpaper.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.connection.second.common.annotation.Anonymous;
import com.connection.second.wallpaper.domain.page.PaperWallRankPage;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.connection.second.common.annotation.Log;
import com.connection.second.common.core.controller.BaseController;
import com.connection.second.common.core.domain.AjaxResult;
import com.connection.second.common.enums.BusinessType;
import com.connection.second.wallpaper.domain.entity.PaperWallRank;
import com.connection.second.wallpaper.service.IPaperWallRankService;
import com.connection.second.common.utils.poi.ExcelUtil;
import com.connection.second.common.core.page.TableDataInfo;

/**
 * 壁纸排名Controller
 * 
 * @author FL
 * @date 2024-11-25
 */
@RestController
@RequestMapping("/wallpaper/wallRank")
public class PaperWallRankController extends BaseController
{
    @Autowired
    private IPaperWallRankService paperWallRankService;

    /**
     * 查询壁纸排名列表
     */
    @Anonymous
    @GetMapping("/list")
    public TableDataInfo list(PaperWallRank paperWallRank)
    {
        startPage();
        List<PaperWallRankPage> list = paperWallRankService.selectPaperWallRankList(paperWallRank);
        return getDataTable(list);
    }


    /**
     * 获取壁纸排名详细信息
     */
    @PreAuthorize("@ss.hasPermi('wallpaper:wallRank:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(paperWallRankService.selectPaperWallRankById(id));
    }

    /**
     * 新增壁纸排名
     */
    @PreAuthorize("@ss.hasPermi('wallpaper:wallRank:add')")
    @Log(title = "壁纸排名", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PaperWallRank paperWallRank)
    {
        return toAjax(paperWallRankService.insertPaperWallRank(paperWallRank));
    }

    /**
     * 修改壁纸排名
     */
    @PreAuthorize("@ss.hasPermi('wallpaper:wallRank:edit')")
    @Log(title = "壁纸排名", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PaperWallRank paperWallRank)
    {
        return toAjax(paperWallRankService.updatePaperWallRank(paperWallRank));
    }

    /**
     * 删除壁纸排名
     */
    @PreAuthorize("@ss.hasPermi('wallpaper:wallRank:remove')")
    @Log(title = "壁纸排名", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(paperWallRankService.deletePaperWallRankByIds(ids));
    }
}
